home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / ConnectionDescriptor.java < prev    next >
Text File  |  1998-08-21  |  5KB  |  162 lines

  1. package symantec.itools.beans;
  2.  
  3.  
  4. //  07/01/97    CAR Created
  5.  
  6. /**
  7.  * A simple class that encapsulates a bean's Visual CafΘ "connection" information as used
  8.  * by the Interaction Wizard.  A Visual CafΘ connection implies a relationship between
  9.  * objects (or between an object and itself) involving either event notification or data
  10.  * transmission.  The Interaction Wizard allows users to graphically build these relationships
  11.  * between objects and then Visual CafΘ is able to generate the code for the specified
  12.  * relationship based on the underlying connection information encapsulated in the
  13.  * ConnectionDescriptor.
  14.  *
  15.  * @version 1.0, July 1, 1997
  16.  *
  17.  * @author  Symantec
  18.  */
  19. public class ConnectionDescriptor extends java.beans.FeatureDescriptor {
  20.  
  21.     /**
  22.      * A constant indicating an input connection.
  23.      * @see #setForm
  24.      */
  25.     public static final String INPUT        = "input";
  26.     /**
  27.      * A constant indicating an output connection.
  28.      * @see #setForm
  29.      */
  30.     public static final String OUTPUT       = "output";
  31.     /**
  32.      * A constant used by SymantecBeanDescriptor when specifying connection information.
  33.      * @see symantec.itools.beans.SymantecBeanDescriptor
  34.      */
  35.     public static final String CONNECTIONS  = "CONNECTIONS";
  36.  
  37.     /**
  38.      * Constructs a default ConnectionDescriptor. Form, type, init, and expr
  39.      * are all empty strings.
  40.      * @see #setForm
  41.      * @see #setType
  42.      * @see #setInit
  43.      * @see #setExpr
  44.      */
  45.     public ConnectionDescriptor() {
  46.         form = "";
  47.         type = "";
  48.         init = "";
  49.         expr = "";
  50.     }
  51.  
  52.     /**
  53.      * Constructs a ConnectionDescriptor with the given form.
  54.      * Type, init, and expr are all empty strings.
  55.      * @param f the form string
  56.      * @see #setType
  57.      * @see #setInit
  58.      * @see #setExpr
  59.      */
  60.     public ConnectionDescriptor(String f) {
  61.         if (f != INPUT && f != OUTPUT)
  62.             throw new IllegalArgumentException("acceptable values are \"input\" or \"output\"");
  63.         form = f;
  64.         type = "";
  65.         init = "";
  66.         expr = "";
  67.     }
  68.  
  69.     /**
  70.      * Constructs a ConnectionDescriptor with the given form, type, init, and
  71.      * expr String values.
  72.      * @param f the form string
  73.      * @param t the type string
  74.      * @param i the init string
  75.      * @param e the expression string
  76.      * @param d a short description
  77.      */
  78.     public ConnectionDescriptor(String f, String t, String i, String e, String d) {
  79.         if (f != INPUT && f != OUTPUT)
  80.             throw new IllegalArgumentException("acceptable values are \"input\" or \"output\"");
  81.         form = f;
  82.         type = t;
  83.         init = i;
  84.         expr = e;
  85.         setShortDescription(d);
  86.     }
  87.  
  88.     /**
  89.      * Gets the current form string.
  90.      * @return the current form
  91.      * @see #setForm
  92.      */
  93.     public String getForm() { return form; }
  94.  
  95.     /**
  96.      * Sets the form string. The form of a connection is either INPUT or OUTPUT. An output
  97.      * connection defines an interaction that returns data; an input connection defines an
  98.      * interaction that sets data, or initiates execution of a method that doesn't take data.
  99.      * @return the new form
  100.      * @see #getForm
  101.      */
  102.     public void setForm(String f) {
  103.         if (f != INPUT && f != OUTPUT)
  104.             throw new IllegalArgumentException("acceptable values are \"input\" or \"output\"");
  105.         form = f;
  106.     }
  107.  
  108.     /**
  109.      * Gets the current type string.
  110.      * @return the current type
  111.      * @see #setType
  112.      */
  113.     public String getType() { return type; }
  114.  
  115.     /**
  116.      * Specifies the Java type of the parameter or return value of this connection.  The most
  117.      * common types are int, boolean, String, and void.
  118.      * @return the new type
  119.      * @see #getType
  120.      */
  121.     public void setType(String t) { type = t; }
  122.  
  123.     /**
  124.      * Gets the current init string.
  125.      * @return the current init
  126.      * @see #setInit
  127.      */
  128.     public String getInit() { return init; }
  129.  
  130.     /**
  131.      * Specifies any initialization code that needs to be present prior to the code generated from
  132.      * the connection expression.  This string is usually blank.
  133.      * @return the new init
  134.      * @see #getInit
  135.      * @see #setExpr
  136.      */
  137.     public void setInit(String i) { init = i; }
  138.  
  139.     /**
  140.      * Gets the current expression string.
  141.      * @return the current expression
  142.      * @see #setExpr
  143.      */
  144.     public String getExpr() { return expr; }
  145.  
  146.     /**
  147.      * Specifies the code fragment that is used to create this connection.  The following replacement
  148.      * variables are allowed in the code fragment:
  149.      * %name%   the name of the class/bean
  150.      * %class%  full classname of the class/bean
  151.      * %arg%    method argument used for input connection data
  152.      * @return the new expression
  153.      * @see #getExpr
  154.      */
  155.     public void setExpr(String e) { expr = e; }
  156.  
  157.     private String form;
  158.     private String type;
  159.     private String init;
  160.     private String expr;
  161. }
  162.